Skip to main content

Constants

QQL allows using various types of constants with different operations with simple types and/or arrays.

info

See Data Types for more information on conversions.

Numeric Constants

  1. Integer constants. Examples: 123, 1669, -362367, 8238 -> Compiles to Int32 type.
  2. Long constants. Examples: 123L, 1669L, -23643787L, 237237723777L -> Compiles to Int64 type.
  3. Decimal constants. Examples: 236.2377, 2366236.23773, -0.237237, 1.36e-5, -1.238e10 -> Compiles to Decimal64 type.
  4. Float64 constants. Examples: 236.2377f, 2366236.23773f, -0.237237f, 1.36e-5f, -1.238e10f -> Compiles to Float64 type.
  5. Time Interval constant. Template {days}d{hours}h{minutes}m{seconds}s{milliseconds}ms. Examples: 1h, 1d10h20m42s500ms, 3000ms -> Compiles to Int64.

Numeric Arrays

  1. Integer arrays. Examples: [126, 2388, -2377], [42] -> Compiles to Array(Int32).
  2. Long arrays. Examples: [126L, 2388, -2377], [126L, 23882377L, -2377L] -> Compiles to Array(Int64)
  3. Decimal64 arrays. Examples: [126.4366, -3277, 2388.238], [0.2388, -0.00002377236, -1.238e10] -> Compiles to Array(Decimal64)
  4. Float64 arrays. Examples: [126.4366f, -3277, 2388.238f], [0.2388f, -0.00002377236, -1.238e10f] -> Compiles to Array(Float64)
  5. Time Interval arrays. Examples: [1h, 5m30s, 1201200L], [2370ms, 1000000L] -> Compiles to Array(Int64)

Boolean Constants and Arrays of Booleans

  1. Boolean. Examples: true, false.
  2. Boolean arrays. Examples: [true, true, false, false], [true].

Timestamp Constants and Arrays of Timestamps

The QQL syntax of date literals is different from SQL. Instead of something like DATE '...', the syntax is '...'d.

Date specification format:

<year>[-<month>[-<day>[ <hour (24)>[:<minute>[:<second>[.<fraction>]]]]]][ <time zone>]

  1. Timestamp. Examples: '2020-10-13 11:22:48'd, '2021-01-01 11:42:48.553'd
  2. Timestamp arrays. Examples: ['2020-10-13 11:22:48'd, '2021-01-01 11:42:48.553'd]

This means that you can specify either a year only, or a year and a month, or a year, a month, and a day, and so on. However, the time zone can be specified or omitted independently. Any omitted values take reasonable defaults, such as January, 1st day of month, the GMT time zone and zeros for all other components.

Examples of valid date literals:

  • '2008'd
  • '2008 America/New_York'd
  • '2008-03-28'd
  • '2008-03-28 America/New_York'd
  • '2008-03-28 14'd
  • '2008-03-28 14:02:59.1'd
  • '2008-03-28 14:02:59.317859261'd

String Literals and Arrays of String Literals

In QQL requests you can embrace a string in a single quotes to make it a string literal.

  1. Varchar (UTF8). Example: 'How are you?'.
  2. Varchar arrays. Examples: ['Hello, it\'s me!', 'Don\'t panic!', 'How are you?'], ['Hello', 'World'].

In your queries you can use both identifiers and string literals after a keyword AS; therefore, embrace your entry in single quotes to make it a string literal.

In the below example we use a string literal to set the alias for the SYMBOL column.

Using string literals in QQL queries.
#Shell format
==> SELECT symbol AS '*Symbol*' FROM securities

>_,TIMESTAMP,SYMBOL,TYPE,*Symbol*
0,_,,SYSTEM,ESZ11
1,_,,SYSTEM,NQZ11
2,_,,SYSTEM,ESU11
3,_,,SYSTEM,NQU11
4,_,,SYSTEM,AAPL
5,_,,SYSTEM
info

Refer to VARCHAR functions for more string literals usage examples.

Char Constants and Arrays of Chars

  1. Char. Examples: '\''c, 'a'c, '1'c.
  2. Char arrays. Examples: ['\''c, 'a'c, '1'c]

Special Characters

Special CharacterDisplay
\'Single quotation
\"Double quotation
\\Backslash
\tTab
\bBackspace
\rCarriage return
\fFormfeed
\nNew line

Example: 'Hello, it\'s me!'